<!DOCTYPE html>
<html lang="zh-CN">
@include('/base.head')
<body>

@include('/business.topNav')

<div class="container-fluid">
    <div class="row">
        @extends('business.leftNav')
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <h2 class="page-header">类别管理 | <button type="button" class="btn btn-primary  btn-sm" data-toggle="modal" data-target="#addArea">添加类别</button></h2>
            @if(session('__Ajax_RedirectFunc_status') == true)
                <div>
                    <div class="alert alert-success alert-dismissible fade in" role="alert">
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        <h3>成功</h3>
                        <p><?php echo session('__Ajax_RedirectFunc_message');?></p>
                        <p><?php echo session('__Ajax_RedirectFunc_plugin');?></p>
                    </div>
                </div>
            @endif
            @if(session('__Ajax_RedirectFunc_status') === false)
                <div >
                    <div class="alert alert-danger alert-dismissible fade in" role="alert">
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        <h3>失败</h3>
                        <p><?php echo session('__Ajax_RedirectFunc_message');?></p>
                        <p><?php echo session('__Ajax_RedirectFunc_plugin');?></p>
                    </div>
                </div>
            @endif

            <div class="panel-body" >
                <div class="modal fade" id="addArea" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                <h4 class="modal-title" id="myModalLabel">添加类别</h4>
                            </div>
                            <div class="modal-body">
                                <form action="/addClass" method="post">
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <br>
                                    <input type="text"  name="goods_class_name" class="form-control" placeholder="添加类别"  required autofocus>
                                    <br>
                            </div>
                            <div class="modal-footer">
                                <button type="submit" class="btn btn-primary">添加</button>
                                <button type="button" class="btn btn-default" data-dismiss="modal">返回</button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <hr>
                <!--表格-->
                <div class="table-responsive">
                    <table class="table table-bordered table-responsive table-striped table-hover">
                        <thead>
                        <tr>
                            <th>类别</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($classData as $data)
                            <tr>
                                <td>{{$data->goods_class_name}}</td>
                                <td><button type="button" class="btn btn-danger  btn-sm" data-toggle="modal" data-target="#delArea{{$data->goods_class_id}}">删除</button></td>
                            </tr>


                            <!--删除种类模态框-->
                            <div class="modal fade" id="delArea{{$data->goods_class_id}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                            <h4 class="modal-title" id="myModalLabel2">警告</h4>
                                        </div>
                                        <div class="modal-body">
                                            <form action="/delClass" method="get">
                                                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                                <input type="hidden" name="goods_class_id" value="{{$data->goods_class_id}}">
                                                <h4>这将会删掉所有此种类的产品，确定要删除吗？</h4>
                                        </div>
                                        <div class="modal-footer">
                                            <button type="submit" class="btn btn-danger">删除</button>
                                            <button type="button" class="btn btn-default" data-dismiss="modal">返回</button>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        @endforeach
                        </tbody>
                    </table>
                    <hr>

                </div>
            </div>

        </div>
    </div>
</div>
</body>
</html>